package jp.bluecab.bluecabsystem.gps;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

public class AppPreferences extends PreferenceActivity {
	
	public static final String KEY_UPDATE_FREQ = "pdate_freq";
	public static final String KEY_LOGIN_ID = "login_id";
	public static final String KEY_SERVER_URL = "server_url";
	
	public void onCreate(Bundle icicle) {
		
		super.onCreate(icicle);
		// 設定画面の設定
		addPreferencesFromResource(R.layout.apppreferences);
	}
	
	/*
	 * 更新間隔を取得
	 */
	public static int getUpdateFreq(Context context) {
		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
		String freq = pref.getString(KEY_UPDATE_FREQ, "60");
		return Integer.parseInt(freq);
	}
	
	/*
	 * ログインID取得
	 */
	public static String getLoginId(Context context) {
		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
		return pref.getString(KEY_LOGIN_ID, "default");
	}
	
	/*
	 * サーバーのURL取得
	 */
	public static String getServerUrl(Context context) {
		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
		return pref.getString(KEY_SERVER_URL, "10.0.0.2");
	}
}
